package com.dz.fz.dao;


import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;


public class DBProvider {
    public static <T> T query(String sql, ResultSetHandler<T> rsh, Object... params) {
        T t_quert = null;
        QueryRunner runner = new QueryRunner(DBCPDataSource.getDataSource());
        try{
            t_quert = runner.query(sql,rsh,params);
        }catch(Exception e){
            System.out.println("Jdbc发生异常"+e.getMessage());
        }
        return t_quert;
    }
    public static int update(String sql, Object... params) {
        int i = 0;
        QueryRunner runner = new QueryRunner(DBCPDataSource.getDataSource());
        try{
            i= runner.update(sql,params);
        }catch(Exception e){
            System.out.println("JDBC发生异常"+e.getMessage());
        }
        return i;
    }
}


